package dp.state;

import dp.state.interfaces.State;

public class HasQuarterState implements State {
	
	private GumballMachine gumballMachine;
	
	public HasQuarterState(GumballMachine gumballMachine) {
		this.gumballMachine = gumballMachine;
	}

	public void dispense() {
		System.out.println("No gumball dispensed");
	}

	public void ejectQuarter() {
		System.out.println("Quarter returned");
		gumballMachine.setState(gumballMachine.getNoQuarterState());
	}

	public void insertQuarter() {
		System.out.println("You can't insert another quarter");
	}

	public void turnCrank() {
		System.out.println("You have turned the crank");
		int roll = (int)(100*Math.random());
		if(roll<10)
			gumballMachine.setState(gumballMachine.getSoldState());
		else
			gumballMachine.setState(gumballMachine.getWinnerState());
	}

}
